﻿@using Wicresoft.UnifyShow.Utility;
@using Wicresoft.UnifyShow.Business;

@{
    var taskStatus = ViewData["TaskStatus"] as EnumDataSource<EnumUtility.TaskStatus>;

    var Model = ViewData["Model"] as TaskModel;
    var isView = Model != null;

    var IsTaskEnd = (bool)ViewData["TaskIsEnd"];
}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/css/global.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/main.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/themes/default/easyui.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/themes/gray/tabs.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/themes/icon.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/css/plan.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.easyui.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/json3.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/plan.js")" type="text/javascript"></script>

</head>

<body>
    <div class="padding20" style="width: 1040px; margin: 0 auto;" id="taskDetail">
        <input type="hidden" id="detailID" value="@(ViewBag.DetailID)" data-model-source="ID" />
        <input type="hidden" id="IsTaskEnd" value="@(IsTaskEnd)" />
        <div class="buttonContainer">
            <input type="button" value="保存" id="btnSave" onclick="saveTask();" />
            <input type="button" value="取消" id="btnCancel" onclick="closeWindow();" />
        </div>

        <div class="parameter">
            <div class="parameter_name">任务名称：</div>
            <div class="parameter_input">
                <input type="text" value="@(isView ? Model.TaskName : "")" data-model-source="TaskName" />
            </div>
        </div>

        @RenderSection("TypeAndLocation", required: false)

        <div class="parameter">
            <div class="parameter_name">任务描述：</div>
            <div class="parameter_input">
                <textarea rows="6" style="width: 97%;" data-model-source="TaskDescription">@(isView ? Model.TaskDescription : "")</textarea>
            </div>
        </div>

        <div class="parameter two-cols">
            <div class="parameter_name">责任人：</div>
            <div class="parameter_input">
                <input type="text" data-model-source="OwnerName" value="@(isView ? Model.OwnerName : "")" data-from="username" />
                <input type="hidden" data-model-source="OwnerID" value="@(isView ? Model.OwnerID.ToString() : "")" data-from="userid" />
                @if (!IsTaskEnd && Model != null && Model.JobType == 3)
                { //一般计划可以转责任人
                    <span class="icon-search" onclick="openResponsibleSearch();"></span>
                }
            </div>
        </div>

        <div class="parameter two-cols">
            <div class="parameter_name">任务状态：</div>
            <div class="parameter_input">
                <select id="taskStatus" data-model-source="Status">
                    @foreach (var item in taskStatus)
                    { 
                        <option value="@item.EnumValue" @((isView && item.EnumValue == Model.Status) ? "selected='selected'" : "")>@item.DisplayValue</option>
                    }
                </select>
            </div>
        </div>

        <div class="parameter two-cols">
            <div class="parameter_name">触发时间：</div>
            <div class="parameter_input">
                <input type="text" data-model-source="BeginDate" class="easyui-datebox" value="@(isView ? Model.BeginDate.ToString("yyyy-MM-dd") : "")" />
            </div>
        </div>

        <div class="parameter two-cols">
            <div class="parameter_name">过期时间：</div>
            <div class="parameter_input">
                <input type="text" data-model-source="EndDate" class="easyui-datebox"  value="@(isView ? Model.EndDate.ToString("yyyy-MM-dd") : "")"/>
            </div>
        </div>

        @RenderBody()

    </div>

    <script type="text/javascript">
        $(function () {
            $('.easyui-datebox').datebox({
                formatter: function (date) {
                    return date.formate('yyyy-MM-dd')
                }
            });
            $('.combo-text').attr('disabled', true);
        });
    </script>
</body>

</html>
